const fs = require('fs');
const zlib=require('zlib');
var data="测试东西";
//读取流
var readerStram = fs.createReadStream("log.txt");

// readerStram.setEncoding('utf-8');

// readerStram.on('data',function(chunk){
//      data+=chunk
// })

// readerStram.on('end',function(){
//     console.log(data)
// })

// readerStram.on('error',function(err){
//     console.log(err.stack);
// })

// console.log("程序执行完毕")
//写入流
var writeStreamm = fs.createWriteStream('outlog.txt');

// writeStreamm.write(data,'utf-8');

// writeStreamm.end();

//处理流事件
// writeStreamm.on('finish',function(){
//     console.log('写入完成')
// })

//管道流
// readerStram.pipe(writeStreamm);

//链式流
readerStram.pipe(zlib.createGzip()).pipe(fs.createWriteStream('outlog.txt.gz'))
